﻿using System;
using System.Collections.Generic;
using System.Text;
using Google.GData.Documents;
using Google.GData.Client;
using Google.GData.Extensions;


namespace GDocUploader.Communication
{
    class Authentification
    {
        public static bool IsLogin = false;
        public static string username { set; get; }
        public static string password { set; get; }
   
       

        public static bool login()
        {
            IsLogin = false;
            if (username.Length == 0) return false;
            if (password.Length == 0) return false;
            if (!username.Contains("@")) return false;
            try
            {
                frmUploader.ServGen = new DocumentsService("GDocUploader");
                frmUploader.ServGen.setUserCredentials(username, password);
                ((GDataRequestFactory)frmUploader.ServGen.RequestFactory).KeepAlive = false;
                DocumentsListQuery query = new DocumentsListQuery();
                frmUploader.ServGen.Query(query);
                IsLogin = true;
                return true;
            }
            catch 
            {
                IsLogin = false;
                return false;
            }
           
           
        }
    }
}
